#!/usr/bin/env python
# -*- coding: iso-8859-1 -*-

import os

def build(bld):
    obj = bld.new_task_gen('cxx', 'cshlib')
    obj.source="""
        instructions.cpp
        registers.cpp
        alias.cpp
        processor.cpp
        interface.cpp
        decoder.cpp
        memory.cpp
        externalPorts.cpp
        irqPorts.cpp
        externalPins.cpp
    """
    obj.uselib = 'BOOST BOOST_FILESYSTEM BOOST_THREAD SYSTEMC_H TLM TRAP'
    obj.includes = '.'
    obj.export_incdirs = '.'
    obj.name = 'leon3_funcAT'
    obj.target = 'leon3_funcAT'

    obj = bld.new_task_gen('pypp')
    obj.source="""
        processor.hpp
        memory.hpp
    """
    obj.uselib = 'BOOST BOOST_FILESYSTEM BOOST_THREAD SYSTEMC_H TLM TRAP BOOST_PYTHON'
    obj.uselib_local = 'systemc leon3_funcAT binutils'
    obj.includes = '.'
    obj.split = 10
    obj.name = 'leon3_funcAT_wrapper'
    obj.target = 'leon3_funcAT_wrapper'
    obj.include = 'scwrapper tlmwrapper trapwrapper'
    obj.start_decls = 'leon3_funcat_trap'
    obj.custom_code = """
for i in mb.global_ns.classes():
    for base in i.recursive_bases:
        if base.related_class.name == 'Instruction':
            i.exclude()
            break
mb.global_ns.class_('Instruction').exclude()
mb.global_ns.class_('LEON3_ABIIf').constructors().exclude()

mb.global_ns.class_('Register').exclude()
mb.global_ns.class_('Register').ignore = False
mb.global_ns.class_('Alias').exclude()
mb.global_ns.class_('Alias').ignore = False
mb.global_ns.class_('InnerField').exclude()
mb.global_ns.class_('InnerField').ignore = False
mb.global_ns.class_('Processor_leon3_funcat').member_function('decode').exclude()
mb.global_ns.class_('Processor_leon3_funcat').member_function('getInterface').call_policies = call_policies.return_value_policy( call_policies.reference_existing_object )
"""
